<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
<h1>项目-登录页</h1>

<button class="btn">登录</button>

<script src="./utils.js"></script>
<script>
$('.btn').onclick = function (){
    // 获取要跳转的页面地址
    let url = localStorage.getItem('currentUrl')

    // 发送登录请求
    ajax({
        type: 'post',
        url: 'http://localhost:8080/users/login',
        data: {
            user: 'xiaocuo',
            pass: '123123'
        },
        dataType: 'json'
    })
    .then((res)=>{
        // alert(res.msg)
        if (res.code === 1) {
            // 登录成功，跳转的指定页面
            if (url) {
                location.href = url
            }
            else{
                location.href = './7-session.html'
            }
        }
    })
}
</script>
</body>
</html>